// @ts-ignore
import { api } from '@/utils/api';

/** 分片上传取消 POST /filePlus/abortMultipartUpload */
export async function filePlusAbortMultipartUpload(
  body: BASE.ID,
  options?: ArgumentsType<typeof api>[1]
): Promise<BASE.IResultFileInfo>;

export async function filePlusAbortMultipartUpload(
  body: BASE.ID,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: true }
): Promise<TupleResponse<BASE.IResultFileInfo>>;

export async function filePlusAbortMultipartUpload(
  body: BASE.ID,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: false }
): Promise<BASE.IResultFileInfo>;

export async function filePlusAbortMultipartUpload(
  body: BASE.ID,
  options?: ArgumentsType<typeof api>[1]
) {
  if (
    (
      options as ArgumentsType<typeof api>[1] & {
        tupleResponse: boolean;
      }
    )?.tupleResponse === true
  ) {
    return api<BASE.IResultFileInfo>(`/app/filePlus/abortMultipartUpload`, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {}),
      tupleResponse: true
    });
  }

  return api<BASE.IResultFileInfo>(`/app/filePlus/abortMultipartUpload`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  });
}

/** 分片上传完成 POST /filePlus/completeMultipartUpload */
export async function filePlusCompleteMultipartUpload(
  body: BASE.ID,
  options?: ArgumentsType<typeof api>[1]
): Promise<BASE.IResultFileInfo>;

export async function filePlusCompleteMultipartUpload(
  body: BASE.ID,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: true }
): Promise<TupleResponse<BASE.IResultFileInfo>>;

export async function filePlusCompleteMultipartUpload(
  body: BASE.ID,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: false }
): Promise<BASE.IResultFileInfo>;

export async function filePlusCompleteMultipartUpload(
  body: BASE.ID,
  options?: ArgumentsType<typeof api>[1]
) {
  if (
    (
      options as ArgumentsType<typeof api>[1] & {
        tupleResponse: boolean;
      }
    )?.tupleResponse === true
  ) {
    return api<BASE.IResultFileInfo>(`/app/filePlus/completeMultipartUpload`, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {}),
      tupleResponse: true
    });
  }

  return api<BASE.IResultFileInfo>(`/app/filePlus/completeMultipartUpload`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  });
}

/** 删除文件数据 POST /filePlus/delete */
export async function filePlusDelete(
  body: BASE.ID,
  options?: ArgumentsType<typeof api>[1]
): Promise<BASE.IResult>;

export async function filePlusDelete(
  body: BASE.ID,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: true }
): Promise<TupleResponse<BASE.IResult>>;

export async function filePlusDelete(
  body: BASE.ID,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: false }
): Promise<BASE.IResult>;

export async function filePlusDelete(body: BASE.ID, options?: ArgumentsType<typeof api>[1]) {
  if (
    (
      options as ArgumentsType<typeof api>[1] & {
        tupleResponse: boolean;
      }
    )?.tupleResponse === true
  ) {
    return api<BASE.IResult>(`/app/filePlus/delete`, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {}),
      tupleResponse: true
    });
  }

  return api<BASE.IResult>(`/app/filePlus/delete`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  });
}

/** 根据url删除文件 POST /filePlus/deleteByUrl */
export async function filePlusDeleteByUrl(
  body: BASE.AutoDtoWithFileplusDeletebyurl,
  options?: ArgumentsType<typeof api>[1]
): Promise<BASE.IResult>;

export async function filePlusDeleteByUrl(
  body: BASE.AutoDtoWithFileplusDeletebyurl,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: true }
): Promise<TupleResponse<BASE.IResult>>;

export async function filePlusDeleteByUrl(
  body: BASE.AutoDtoWithFileplusDeletebyurl,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: false }
): Promise<BASE.IResult>;

export async function filePlusDeleteByUrl(
  body: BASE.AutoDtoWithFileplusDeletebyurl,
  options?: ArgumentsType<typeof api>[1]
) {
  if (
    (
      options as ArgumentsType<typeof api>[1] & {
        tupleResponse: boolean;
      }
    )?.tupleResponse === true
  ) {
    return api<BASE.IResult>(`/app/filePlus/deleteByUrl`, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {}),
      tupleResponse: true
    });
  }

  return api<BASE.IResult>(`/app/filePlus/deleteByUrl`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  });
}

/** 根据文件id下载文件 POST /filePlus/downloadById */
export async function filePlusDownloadById(
  body: BASE.AutoDtoWithFileplusDownloadbyid,
  options?: ArgumentsType<typeof api>[1]
): Promise<any>;

export async function filePlusDownloadById(
  body: BASE.AutoDtoWithFileplusDownloadbyid,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: true }
): Promise<TupleResponse<any>>;

export async function filePlusDownloadById(
  body: BASE.AutoDtoWithFileplusDownloadbyid,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: false }
): Promise<any>;

export async function filePlusDownloadById(
  body: BASE.AutoDtoWithFileplusDownloadbyid,
  options?: ArgumentsType<typeof api>[1]
) {
  if (
    (
      options as ArgumentsType<typeof api>[1] & {
        tupleResponse: boolean;
      }
    )?.tupleResponse === true
  ) {
    return api<any>(`/app/filePlus/downloadById`, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {}),
      tupleResponse: true
    });
  }

  return api<any>(`/app/filePlus/downloadById`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  });
}

/** 根据文件url下载文件 POST /filePlus/downloadByUrl */
export async function filePlusDownloadByUrl(
  body: BASE.AutoDtoWithFileplusDownloadbyurl,
  options?: ArgumentsType<typeof api>[1]
): Promise<any>;

export async function filePlusDownloadByUrl(
  body: BASE.AutoDtoWithFileplusDownloadbyurl,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: true }
): Promise<TupleResponse<any>>;

export async function filePlusDownloadByUrl(
  body: BASE.AutoDtoWithFileplusDownloadbyurl,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: false }
): Promise<any>;

export async function filePlusDownloadByUrl(
  body: BASE.AutoDtoWithFileplusDownloadbyurl,
  options?: ArgumentsType<typeof api>[1]
) {
  if (
    (
      options as ArgumentsType<typeof api>[1] & {
        tupleResponse: boolean;
      }
    )?.tupleResponse === true
  ) {
    return api<any>(`/app/filePlus/downloadByUrl`, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {}),
      tupleResponse: true
    });
  }

  return api<any>(`/app/filePlus/downloadByUrl`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  });
}

/** 根据文件id下载zip格式文件 POST /filePlus/downloadZipById */
export async function filePlusDownloadZipById(
  body: BASE.ID,
  options?: ArgumentsType<typeof api>[1]
): Promise<any>;

export async function filePlusDownloadZipById(
  body: BASE.ID,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: true }
): Promise<TupleResponse<any>>;

export async function filePlusDownloadZipById(
  body: BASE.ID,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: false }
): Promise<any>;

export async function filePlusDownloadZipById(
  body: BASE.ID,
  options?: ArgumentsType<typeof api>[1]
) {
  if (
    (
      options as ArgumentsType<typeof api>[1] & {
        tupleResponse: boolean;
      }
    )?.tupleResponse === true
  ) {
    return api<any>(`/app/filePlus/downloadZipById`, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {}),
      tupleResponse: true
    });
  }

  return api<any>(`/app/filePlus/downloadZipById`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  });
}

/** 生成预签名Url POST /filePlus/generateSignedUrl */
export async function filePlusGenerateSignedUrl(
  body: BASE.AutoDtoWithFileplusGeneratesignedurl,
  options?: ArgumentsType<typeof api>[1]
): Promise<BASE.IResultString>;

export async function filePlusGenerateSignedUrl(
  body: BASE.AutoDtoWithFileplusGeneratesignedurl,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: true }
): Promise<TupleResponse<BASE.IResultString>>;

export async function filePlusGenerateSignedUrl(
  body: BASE.AutoDtoWithFileplusGeneratesignedurl,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: false }
): Promise<BASE.IResultString>;

export async function filePlusGenerateSignedUrl(
  body: BASE.AutoDtoWithFileplusGeneratesignedurl,
  options?: ArgumentsType<typeof api>[1]
) {
  if (
    (
      options as ArgumentsType<typeof api>[1] & {
        tupleResponse: boolean;
      }
    )?.tupleResponse === true
  ) {
    return api<BASE.IResultString>(`/app/filePlus/generateSignedUrl`, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {}),
      tupleResponse: true
    });
  }

  return api<BASE.IResultString>(`/app/filePlus/generateSignedUrl`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  });
}

/** 获取单个文件数据 POST /filePlus/get */
export async function filePlusGet(
  body: BASE.ID,
  options?: ArgumentsType<typeof api>[1]
): Promise<BASE.IResultFileDetail>;

export async function filePlusGet(
  body: BASE.ID,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: true }
): Promise<TupleResponse<BASE.IResultFileDetail>>;

export async function filePlusGet(
  body: BASE.ID,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: false }
): Promise<BASE.IResultFileDetail>;

export async function filePlusGet(body: BASE.ID, options?: ArgumentsType<typeof api>[1]) {
  if (
    (
      options as ArgumentsType<typeof api>[1] & {
        tupleResponse: boolean;
      }
    )?.tupleResponse === true
  ) {
    return api<BASE.IResultFileDetail>(`/app/filePlus/get`, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {}),
      tupleResponse: true
    });
  }

  return api<BASE.IResultFileDetail>(`/app/filePlus/get`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  });
}

/** 分片上传初始化 POST /filePlus/initiateMultipartUpload */
export async function filePlusInitiateMultipartUpload(
  body: BASE.AutoDtoWithFileplusInitiatemultipartupload,
  options?: ArgumentsType<typeof api>[1]
): Promise<BASE.IResultFileInfo>;

export async function filePlusInitiateMultipartUpload(
  body: BASE.AutoDtoWithFileplusInitiatemultipartupload,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: true }
): Promise<TupleResponse<BASE.IResultFileInfo>>;

export async function filePlusInitiateMultipartUpload(
  body: BASE.AutoDtoWithFileplusInitiatemultipartupload,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: false }
): Promise<BASE.IResultFileInfo>;

export async function filePlusInitiateMultipartUpload(
  body: BASE.AutoDtoWithFileplusInitiatemultipartupload,
  options?: ArgumentsType<typeof api>[1]
) {
  if (
    (
      options as ArgumentsType<typeof api>[1] & {
        tupleResponse: boolean;
      }
    )?.tupleResponse === true
  ) {
    return api<BASE.IResultFileInfo>(`/app/filePlus/initiateMultipartUpload`, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {}),
      tupleResponse: true
    });
  }

  return api<BASE.IResultFileInfo>(`/app/filePlus/initiateMultipartUpload`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  });
}

/** 列出分片上传的所有块 POST /filePlus/listParts */
export async function filePlusListParts(
  body: BASE.ID,
  options?: ArgumentsType<typeof api>[1]
): Promise<BASE.IResultListFilePartInfo>;

export async function filePlusListParts(
  body: BASE.ID,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: true }
): Promise<TupleResponse<BASE.IResultListFilePartInfo>>;

export async function filePlusListParts(
  body: BASE.ID,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: false }
): Promise<BASE.IResultListFilePartInfo>;

export async function filePlusListParts(body: BASE.ID, options?: ArgumentsType<typeof api>[1]) {
  if (
    (
      options as ArgumentsType<typeof api>[1] & {
        tupleResponse: boolean;
      }
    )?.tupleResponse === true
  ) {
    return api<BASE.IResultListFilePartInfo>(`/app/filePlus/listParts`, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {}),
      tupleResponse: true
    });
  }

  return api<BASE.IResultListFilePartInfo>(`/app/filePlus/listParts`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  });
}

/** 获取文件分页数据 POST /filePlus/page */
export async function filePlusPage(
  body: BASE.FileDetailQuery,
  options?: ArgumentsType<typeof api>[1]
): Promise<BASE.IResultIPageFileDetail>;

export async function filePlusPage(
  body: BASE.FileDetailQuery,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: true }
): Promise<TupleResponse<BASE.IResultIPageFileDetail>>;

export async function filePlusPage(
  body: BASE.FileDetailQuery,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: false }
): Promise<BASE.IResultIPageFileDetail>;

export async function filePlusPage(
  body: BASE.FileDetailQuery,
  options?: ArgumentsType<typeof api>[1]
) {
  if (
    (
      options as ArgumentsType<typeof api>[1] & {
        tupleResponse: boolean;
      }
    )?.tupleResponse === true
  ) {
    return api<BASE.IResultIPageFileDetail>(`/app/filePlus/page`, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {}),
      tupleResponse: true
    });
  }

  return api<BASE.IResultIPageFileDetail>(`/app/filePlus/page`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  });
}

/** 上传文件 POST /filePlus/upload */
export async function filePlusUpload(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: BASE.filePlusUploadParams,
  body: {},
  file?: File,
  options?: ArgumentsType<typeof api>[1]
): Promise<BASE.IResultFileInfo>;

export async function filePlusUpload(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: BASE.filePlusUploadParams,
  body: {},
  file?: File,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: true }
): Promise<TupleResponse<BASE.IResultFileInfo>>;

export async function filePlusUpload(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: BASE.filePlusUploadParams,
  body: {},
  file?: File,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: false }
): Promise<BASE.IResultFileInfo>;

export async function filePlusUpload(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: BASE.filePlusUploadParams,
  body: {},
  file?: File,
  options?: ArgumentsType<typeof api>[1]
) {
  const formData = new FormData();

  if (file) {
    formData.append('file', file);
  }

  Object.keys(body).forEach((ele) => {
    const item = (body as any)[ele];

    if (item !== undefined && item !== null) {
      formData.append(
        ele,
        typeof item === 'object' && !(item instanceof File) ? JSON.stringify(item) : item
      );
    }
  });

  if (
    (
      options as ArgumentsType<typeof api>[1] & {
        tupleResponse: boolean;
      }
    )?.tupleResponse === true
  ) {
    return api<BASE.IResultFileInfo>(`/app/filePlus/upload`, {
      method: 'POST',
      params: {
        ...params
      },
      data: formData,
      requestType: 'form',
      ...(options || {}),
      tupleResponse: true
    });
  }

  return api<BASE.IResultFileInfo>(`/app/filePlus/upload`, {
    method: 'POST',
    params: {
      ...params
    },
    data: formData,
    requestType: 'form',
    ...(options || {})
  });
}

/** 分片上传文件 POST /filePlus/uploadPart */
export async function filePlusUploadPart(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: BASE.filePlusUploadPartParams,
  options?: ArgumentsType<typeof api>[1]
): Promise<BASE.IResultFilePartInfo>;

export async function filePlusUploadPart(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: BASE.filePlusUploadPartParams,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: true }
): Promise<TupleResponse<BASE.IResultFilePartInfo>>;

export async function filePlusUploadPart(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: BASE.filePlusUploadPartParams,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: false }
): Promise<BASE.IResultFilePartInfo>;

export async function filePlusUploadPart(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: BASE.filePlusUploadPartParams,
  options?: ArgumentsType<typeof api>[1]
) {
  if (
    (
      options as ArgumentsType<typeof api>[1] & {
        tupleResponse: boolean;
      }
    )?.tupleResponse === true
  ) {
    return api<BASE.IResultFilePartInfo>(`/app/filePlus/uploadPart`, {
      method: 'POST',
      params: {
        ...params
      },
      ...(options || {}),
      tupleResponse: true
    });
  }

  return api<BASE.IResultFilePartInfo>(`/app/filePlus/uploadPart`, {
    method: 'POST',
    params: {
      ...params
    },
    ...(options || {})
  });
}
